# Maintainer: Leonidas Spyropoulos <artafinde@archlinux.org>

pkgname=goaurrpc
pkgver=1.2.3
pkgrel=2
license=('MIT')
pkgdesc="An implementation of the aurweb /rpc service in go"
depends=('glibc')
makedepends=('go' 'git')
arch=('loong64' 'x86_64')
url="https://github.com/moson-mo/goaurrpc"
_tag_commit=5ffa987642b5886ccb290a80a882dee9938e0560 # git show-ref -d v1.2.3
source=("git+https://github.com/moson-mo/goaurrpc.git#tag=${_tag_commit}?signed"
        goaurrpc.service
        goaurrpc.sysusers)
sha256sums=('SKIP'
            'e6a298e647fcf3b255d9886180b992f0dc447e763509c50513473f6d9b9ac5e3'
            '45ac878e62e8e43c55645ebbd71fc8e10ce32c81d1a769979f48ac5f25392ff3')
validpgpkeys=(
  D5AD89388A7C6C9C22E790994A4760AB4EE15296  # Mario Oenning <moson-mo@users.noreply.github.com>, retrieved from https://github.com/moson-mo.gpg
)

prepare() {
  cd ${pkgname}
  mkdir -p dist/
}

build() {
  cd ${pkgname}
  local _BUILDINFO="-X 'main.version=v${pkgver}'"
  go build \
    -trimpath \
    -buildmode=pie \
    -mod=readonly \
    -modcacherw \
    -ldflags "-linkmode external -extldflags \"${LDFLAGS}\" ${_BUILDINFO}" \
    -o dist/goaurrpc \
    .
}

check() {
  cd ${pkgname}
  go test ./...
}

package() {
  cd ${pkgname}
  install -vDm 755 dist/${pkgname} "${pkgdir}/usr/bin/${pkgname}"
  install -vDm 644 LICENSE  "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
  install -vDm 644 "${srcdir}"/${pkgname}.service "${pkgdir}/usr/lib/systemd/system/${pkgname}.service"
  install -vDm 644 "${srcdir}"/${pkgname}.sysusers "${pkgdir}/usr/lib/sysusers.d/${pkgname}.conf"
  install -vDm 644 fromfile.conf "${pkgdir}/usr/share/doc/${pkgname}/fromfile.conf.sample"
  install -vDm 644 sample.conf "${pkgdir}/usr/share/doc/${pkgname}/sample.conf.sample"
}

# vim:set ts=2 sw=2 et:
